package com.x.chalk.controller;

import com.x.chalk.config.SystemConfig;
import com.x.chalk.service.intf.UserSignService;
import com.x.chalk.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@CrossOrigin
@RequestMapping("/api/userSign/")
@Api(tags = "签到相关操作")
public class UserSignController {

    @Autowired
    private UserSignService userSignService;

    @GetMapping("checkSign.do")
    @ApiOperation(value = "查询是否能签到")
    private R checkSign(HttpServletRequest request){
        return userSignService.checkSign(request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @GetMapping("createSign.do")
    @ApiOperation(value = "签到")
    private R createSign(HttpServletRequest request){
        return userSignService.createSign(request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @GetMapping("queryDays.do")
    @ApiOperation(value = "查询连续签到天数")
    public R queryDays(HttpServletRequest request) {
        return userSignService.queryDays(request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @GetMapping("queryAccumulatedDays.do")
    @ApiOperation(value = "查询累计签到天数")
    public R queryAccumulatedDays(HttpServletRequest request) {
        return userSignService.queryAccumulatedDays(request.getHeader(SystemConfig.HEADER_TOKEN));
    }
}
